package com.example.ByteStream;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author Jason
 * @PACKAGE_NAME com.example.ByteStream
 * @Description 字节缓冲流写入文件BufferedOutputStream
 * @date 2023-12-11 21:27
 */
public class BufferedOutputStreamDemo {
    public static void main(String[] args) throws IOException {
        //1.创建流对象
        FileOutputStream fos = new FileOutputStream("d:\\bbb.txt");
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        //2.写入文件
        for (int i = 0; i < 10; i++) {
            bos.write("helloworld ".getBytes());//写入8K的缓冲区
            bos.flush();//刷新到硬盘
        }
        bos.close();
    }
}
